<!--
 * @Author: chenjianxin
 * @Date: 2020-07-01 15:25:24
 * @LastEditTime: 2021-02-24 16:04:22
 * @LastEditors: ganxiaochuan
 * @Description: In User Settings Edit
 * @FilePath: \ui-standard\src\App.vue
-->
<template>
  <div id="app">
    <keep-alive>
      <router-view></router-view>
    </keep-alive>
  </div>
</template>
<script>
import apis from '@/apis'
import { mapState, mapMutations } from 'vuex'
import CONFIG from '@/config'

export default {
  computed: {
    ...mapState(['CONFIG', 'DROPDOWNBOX'])
  },
  mounted() {
    this.getConfig()
  },
  created () {
    this.$http
			.get(apis._api_dict_getDictByGroupNos, {
				params: { groupNos: 'SYSTEM_URL' },
			})
			.then((res) => {
				if (res.data.code === 200) {
					const { data } = res.data
					const newDict = { ...this.DROPDOWNBOX, ...data }
					if (newDict) {
						this.setDictData({ ...newDict })
					}
				}
			})
  },
  methods: {
    ...mapMutations(['setConfig', 'setDictData']),
    /**
     * @description: 获取基础设置  滑块开关 后端时间戳 logo 系统名 等(对接新后端阻止此事件)
     * @param {type} 
     * @return {type} 
     */
    getConfig() {
      return
      this.$http.post(apis.OptionConfig_GetConfig, {
        sysCode: CONFIG.SYS_CODE,
        clientType: 1
      }).then(res => {
        if (res.data.code === 200) {
          const { data } = res.data
          // data.timestamp = new Date().getTime() - data.timestamp
          this.setConfig({...CONFIG, ...data})
          this.changeFavicon(data.iconLogicPath)
          document.title = data.systemName
        }
      })
    },
    changeFavicon (link) {
      let $favicon = document.querySelector('link[rel="icon"]');
      // If a <link rel="icon"> element already exists,
      // change its href to the given link.
      if ($favicon !== null) {
        $favicon.href = link;
        // Otherwise, create a new element and append it to <head>.
      } else {
        $favicon = document.createElement("link");
        $favicon.rel = "icon";
        $favicon.href = link;
        document.head.appendChild($favicon)
      }
    }
  }
}
</script>
<style>
body {
  margin: 0;
  padding: 0;
  font-size: 12px;
}
#app {
  min-height: 100vh;
}
</style>
